//
//  FinishBottomView.m
//  51易借
//
//  Created by 张睿 on 2017/8/31.
//  Copyright © 2017年 张睿. All rights reserved.
//

#import "FinishBottomView.h"



@interface FinishBottomView ()

@property (nonatomic, weak)UILabel * workLabel;
@property (nonatomic, weak)UIImageView * oneRightView;
@property (nonatomic, weak)UIButton * oneBackButton;
@property (nonatomic, weak)UIView * lineView;
@property (nonatomic, weak)UILabel * moreInfoLabel;

@property (nonatomic, weak)UIImageView * twoRightView;
@property (nonatomic, weak)UIButton * twoBackButton;

@end

@implementation FinishBottomView



- (instancetype)initWithFrame:(CGRect)frame{
    
    if ([super initWithFrame:frame]) {
        
        self.backgroundColor = [UIColor whiteColor];
        [self setupUI];
    }
    
    return self;
}


- (void)setupUI{
    
    UILabel * workLabel = [UILabel new];
    
    workLabel.textColor = ColorWithRGB(0x303c41);
//    workLabel.font = [UIFont fontWithName:TYPE_FACE size:14 * SCREENH6];
    workLabel.font = [UIFont systemFontOfSize:14.5 * SCREENH6];
    workLabel.textAlignment = NSTextAlignmentLeft;
    workLabel.text = @"工作信息";
    
    self.workLabel = workLabel;
    
    [self addSubview:self.workLabel];
    
    
    UIImageView * oneRightView = [UIImageView new];
    
    oneRightView.image = [UIImage imageNamed:@"倒三角-箭头"];
    
    self.oneRightView = oneRightView;
    
    [self addSubview:self.oneRightView];
    
    
    
    UILabel * workValueLabel = [UILabel new];
    
    workValueLabel.textColor = ColorWithRGB(0x7f7f7f);
//    workValueLabel.font = [UIFont fontWithName:TYPE_FACE size:14 * SCREENH6];
    workValueLabel.font = [UIFont systemFontOfSize:14.5 * SCREENH6];
    workValueLabel.textAlignment = NSTextAlignmentRight;
    workValueLabel.text = @"未完善";
    
    self.workValueLabel = workValueLabel;
    
    [self addSubview:self.workValueLabel];
    
    UIButton * oneBackButton = [UIButton new];
    
    [oneBackButton setBackgroundColor:[UIColor clearColor]];
    [oneBackButton addTarget:self action:@selector(didBackButton:) forControlEvents:UIControlEventTouchUpInside];
    
    self.oneBackButton = oneBackButton;
    
    [self addSubview:self.oneBackButton];
    
    UIView * lineView = [UIView new];
    
    lineView.backgroundColor = ColorWithRGB(0xdbdbdb);
    
    self.lineView = lineView;
    
    [self addSubview:self.lineView];
    
    
    UILabel * moreInfoLabel = [UILabel new];
    
    moreInfoLabel.textColor = ColorWithRGB(0x303c41);
//    moreInfoLabel.font = [UIFont fontWithName:TYPE_FACE size:14 * SCREENH6];
    moreInfoLabel.font = [UIFont systemFontOfSize:14.5 * SCREENH6];
    moreInfoLabel.textAlignment = NSTextAlignmentLeft;
    moreInfoLabel.text = @"更多信息";
    
    self.moreInfoLabel = moreInfoLabel;
    
    [self addSubview:self.moreInfoLabel];
    
    
    UIImageView * twoRightView = [UIImageView new];
    
    twoRightView.image = [UIImage imageNamed:@"倒三角-箭头"];
    
    self.twoRightView = twoRightView;
    
    [self addSubview:self.twoRightView];
    
    
    
    UILabel * moreInfoValueLabel = [UILabel new];
    
    moreInfoValueLabel.textColor = ColorWithRGB(0x7f7f7f);
//    moreInfoValueLabel.font = [UIFont fontWithName:TYPE_FACE size:14 * SCREENH6];
    moreInfoValueLabel.font = [UIFont systemFontOfSize:14.5 * SCREENH6];
    moreInfoValueLabel.textAlignment = NSTextAlignmentRight;
    moreInfoValueLabel.text = @"未完善";
    
    self.moreInfoValueLabel = moreInfoValueLabel;
    
    [self addSubview:self.moreInfoValueLabel];
    
    
    UIButton * twoBackButton = [UIButton new];
    
    [twoBackButton setBackgroundColor:[UIColor clearColor]];
    [twoBackButton addTarget:self action:@selector(didBackButton:) forControlEvents:UIControlEventTouchUpInside];
    
    self.twoBackButton = twoBackButton;
    
    [self addSubview:self.twoBackButton];
    
}


- (void)layoutSubviews{

    [self.workLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self).offset(17 * SCREENH6);
        make.leading.mas_equalTo(self).offset(10 * SCREENH6);
    }];

    [self.oneRightView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self).offset(-7 * SCREENH6);
        make.centerY.mas_equalTo(self.workLabel);
        make.width.mas_equalTo(8 * SCREENH6);
        make.height.mas_equalTo(15 * SCREENH6);
    }];
    
    [self.workValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.oneRightView);
        make.trailing.mas_equalTo(self.oneRightView.mas_leading).offset(-10 * SCREENH6);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self).offset(48.5 * SCREENH6);
        make.height.mas_equalTo(1 * SCREENH6);
        make.leading.mas_equalTo(self).offset(5 * SCREENH6);
        make.trailing.mas_equalTo(self).offset(-5 * SCREENH6);
    }];
    
    [self.oneBackButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.top.mas_equalTo(self);
        make.bottom.mas_equalTo(self.lineView.mas_top);
    }];
    
    [self.moreInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.workLabel);
        make.top.mas_equalTo(self.lineView.mas_bottom).offset(17 * SCREENH6);
    }];
    
    [self.twoRightView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.height.with.mas_equalTo(self.oneRightView);
        make.centerY.mas_equalTo(self.moreInfoLabel);
    }];
    
    [self.moreInfoValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.workValueLabel);
        make.centerY.mas_equalTo(self.moreInfoLabel);
    }];
    
    [self.twoBackButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.bottom.mas_equalTo(self);
        make.top.mas_equalTo(self.lineView.mas_bottom);
    }];
}


- (void)didBackButton:(UIButton *)button{
    
    if (button == self.oneBackButton) {
        
      if(self.workBLock)
      {
          self.workBLock();
      }
        
    }else{
        if(self.moreBlock)
        {
            self.moreBlock();
        }
    }
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
